import { createRouter, createWebHistory } from "vue-router";
import HomeView from "../views/HomeView.vue";

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: "/:abc*",
      redirect: "/404",
    },
    {
      path: "/",
      name: "home",
      redirect: "list", // 重定向到商品列表页面
      component: HomeView,
    },
    {
      path: "/list",
      name: "list",
      component: () => import("../views/product-list/index.vue"),
      meta: {
        title: "商品列表",
      },
    },
    {
      path: "/cart",
      name: "cart",
      component: () => import("../views/cart/index.vue"),
      meta: {
        title: "购物车",
      },
    },
    {
      path: "/404",
      name: "404",
      component: () => import("../views/404.vue"),
      meta: {
        title: "404 NOTFOUND",
      },
    },
    {
      path: "/product/:id",
      name: "productId",
      component: () => import("../views/product-details/index.vue"),
    },
  ],
});

export default router;
